Gender Split

df_stats
Country Year Statistic value
0 Fiji 1990-01-01 Employment rate NaN
1 Fiji 1991-01-01 Employment rate NaN
2 Fiji 1992-01-01 Employment rate NaN
3 Fiji 1993-01-01 Employment rate NaN
4 Fiji 1994-01-01 Employment rate NaN
... ... ... ... ...
37419 Trinidad and Tobago 2013-01-01 Depression (%) 6.678528
37420 Trinidad and Tobago 2014-01-01 Depression (%) 6.676064
37421 Trinidad and Tobago 2015-01-01 Depression (%) 6.667202
37422 Trinidad and Tobago 2016-01-01 Depression (%) 6.659460
37423 Trinidad and Tobago 2017-01-01 Depression (%) 6.652726

37424 rows × 4 columns

from vega_datasets import data

source = data.iowa_electricity()
print(df_stats.Statistic.unique())
df
['Employment rate' 'Life satisfaction' 'Perceived health'
 'Satisfaction with time use' 'Social support'
 'Time spent in social interactions' 'Divorce Rate' 'Depression (%)']
Country country_code geometry Year Depression in males (%) Depression in females (%) Population (historical estimates) Continent id Access to green space Employment rate Life satisfaction Perceived health Satisfaction with time use Social support Time spent in social interactions Divorce Rate Depression (%)
0 Fiji FJI MULTIPOLYGON (((180 -16.06713266364245, 180 -1... 1990-01-01 2.565040 3.627058 728575.0 NaN 242 NaN NaN NaN NaN NaN NaN NaN NaN 6.192097
1 Fiji FJI MULTIPOLYGON (((180 -16.06713266364245, 180 -1... 1991-01-01 2.574759 3.637601 735398.0 NaN 242 NaN NaN NaN NaN NaN NaN NaN NaN 6.212360
2 Fiji FJI MULTIPOLYGON (((180 -16.06713266364245, 180 -1... 1992-01-01 2.583960 3.647769 744470.0 NaN 242 NaN NaN NaN NaN NaN NaN NaN NaN 6.231729
3 Fiji FJI MULTIPOLYGON (((180 -16.06713266364245, 180 -1... 1993-01-01 2.594349 3.657140 754962.0 NaN 242 NaN NaN NaN NaN NaN NaN NaN NaN 6.251489
4 Fiji FJI MULTIPOLYGON (((180 -16.06713266364245, 180 -1... 1994-01-01 2.602736 3.663786 765607.0 NaN 242 NaN NaN NaN NaN NaN NaN NaN NaN 6.266522
... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ...
4734 Trinidad and Tobago TTO POLYGON ((-61.68000000000001 10.76, -61.105 10... 2013-01-01 2.869620 3.808907 1353708.0 NaN 780 NaN NaN NaN NaN NaN NaN NaN NaN 6.678528
4735 Trinidad and Tobago TTO POLYGON ((-61.68000000000001 10.76, -61.105 10... 2014-01-01 2.870082 3.805982 1362337.0 NaN 780 NaN NaN NaN NaN NaN NaN NaN NaN 6.676064
4736 Trinidad and Tobago TTO POLYGON ((-61.68000000000001 10.76, -61.105 10... 2015-01-01 2.867165 3.800037 1370332.0 North America 780 NaN NaN NaN NaN NaN NaN NaN NaN 6.667202
4737 Trinidad and Tobago TTO POLYGON ((-61.68000000000001 10.76, -61.105 10... 2016-01-01 2.864625 3.794836 1377563.0 NaN 780 NaN NaN NaN NaN NaN NaN NaN NaN 6.659460
4738 Trinidad and Tobago TTO POLYGON ((-61.68000000000001 10.76, -61.105 10... 2017-01-01 2.862335 3.790391 1384060.0 NaN 780 NaN NaN NaN NaN NaN NaN NaN NaN 6.652726

4678 rows × 18 columns

bar_slider = alt.Chart(df).mark_area().encode(
    x='Year',
    y='Population (historical estimates)',
    color ='Country'
).properties(
    height=300
).add_selection(select_year)

employ_scatter = alt.Chart(df).mark_circle().encode(
    x='Depression (%)',
    y='Employment rate',
    color = 'Country',
    opacity=alt.condition(
        select_year,
        alt.value(0.7), alt.value(0.1)
    )
)

best_line = scatter_plot.transform_regression('Depression (%)','Employement rate').mark_line()

(employ_scatter + best_line) & bar_slider